<template>
  <el-table
    :data="tableData"
    stripe
    border
    fit
    highlight-current-row
    style="width: 100%">
    <el-table-column
      prop="s_id"
      label="学号"
      width="180"
      height="180">
    </el-table-column>
    <el-table-column
      prop="user_name"
      label="姓名"
      width="180">
    </el-table-column>
    <el-table-column
      prop="user_password"
      label="密码">
    </el-table-column>
    <el-table-column
      prop="student_name"
      label="姓名">
    </el-table-column>
    <el-table-column
      prop="phone"
      label="手机号">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="120">
      <template slot-scope="scope">
        <el-button
          @click.native.prevent="deleteRow(scope.$index, tableData)"
          type="text"
          size="small">
          移除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
    data(){
        return {
            tableData:[]
        }
    },
    created(){
        this.$axios.post('/api/admin/queryAllStudent').then(res=>{
            this.tableData=res.data;
            
        })
    },
    methods: {
      deleteRow(index, rows) {
        this.$axios.post('/api/admin/DeleteStudent',this.$qs.stringify({
          s_id:rows[index].s_id})).then(()=>{
            rows.splice(index, 1);
            this.$message.success('删除成功');
        }).catch(()=>{
          this.$message.error('删除失败');
        })
        
        
      }
    }
}
</script>

<style>

</style>